package modeller.databasedesignmodel.query;

import modeller.databasedesignmodel.Attribute;
import modeller.databasedesignmodel.relation.Relation;
import modeller.databasedesignmodel.servicedemand.transaction.sqlquery.demandFetcher.ISQLQueryServiceDemandCalculator;
import modeller.databasedesignmodel.servicedemand.IServiceDemand;
import modeller.databasedesignmodel.transaction.SQLQuery;
import queped.SerializablePair;

import java.util.HashSet;

/**
 * Created by IntelliJ IDEA.
 * User: Jason Ye
 * Date: 05/02/2012
 * Time: 12:17
 */
public class UpdateDeleteQuery extends SQLQuery {
    private int numMatchingRows;

    public UpdateDeleteQuery(int numMatchingRows, SerializablePair<Relation, HashSet<Attribute>> relationHashSetPair) {
        super(relationHashSetPair);

        this.numMatchingRows = numMatchingRows;
    }

    public int getNumMatchingRows() {
        return numMatchingRows;
    }


    @Override
    public String myToString() {

        return "\nUPDATE/DELETE Query on RELATION: "
                + getRelation().first.getRelationName()
                + " which is conditioned on the following attributes: "
                + getPrintedAttributeList();

    }

    @Override
    public IServiceDemand acceptCalculation(ISQLQueryServiceDemandCalculator visitor) {
        return visitor.calculate(this);
    }


}
